<template>
  <!--  1.顶部导航-->
  <div>
    <van-nav-bar
        title="个人资料"
        left-text="返回"
        left-arrow
        @click-left="back()"
    />
  </div>
  <div>
    <div>
      <van-divider />
      <div>
        <van-cell value="" is-link>
          <!-- 使用 title 插槽来自定义标题 -->
          <template #title>
            <div style="dispaly:flex;align-items:center;">
              <van-image
                  round
                  width="3rem"
                  height="3rem"
                  :src="img"></van-image>
              <span class="custom-title">更换头像</span>
            </div>

          </template>
        </van-cell>
      </div>
      <van-divider />

    </div>
  </div>


    <p>
      <van-field v-model="userDetail.name" type="text" label="昵称" disabled/>
    </p>

  <div>
    <van-cell-group inset>

      <van-field v-model="userDetail.city" type="text" label="所在城市" />


      <van-field v-model="userDetail.introduction" type="text" label="简介" />


      <van-field  type="text" label="我的实名认证" disabled />


      <van-field v-model="userDetail.sex" type="text" label="性别" />

      <van-field v-model="userDetail.hobby" type="text" label="运动偏好" />

      <van-field v-model="userDetail.birthday" type="text" label="生日" />

      <van-field v-model="userDetail.tall" type="text" label="身高" />

      <van-field v-model="userDetail.weight" type="text" label="体重" />
    </van-cell-group>
  </div>
  <div>
    <van-button type="primary" @click="tj()">提交</van-button>
  </div>

</template>


<script>
export default {


  name: "UpdateDataView",
  data() {
    return{
      img:require("../assets/images/imgs-tx.png"),
      name:"",
      city:"",
      introduction: "",
      sex:"",
      hobby:"",
      birthday: "",
      tall:"",
      weight: "",

      userDetail:{
        uid:this.$store.state.token,
        name: "汪老六",
        img: "https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg",
        city: "北京市大兴区",
        introduction: "一起燃烧脂肪吧",
        sex: "男",
        hobby: "跑步,游泳",
        birthday: "2022-05-18 11:20:50",
        tall: 180+"cm",
        weight: 70+"kg"
      }
    }
  },
  mounted() {
    this.axios.get("/api/userpage/all.do").then((res)=>{
      if (res.data.code==200) {
        //console.log(res.data.data);
        this.userDetail=res.data.data;
      }
    })
  },
  methods:{
    back(){
      history.back();
    },
    setup() {
    },
    tj(){
      //请求接口 实现动态发布
      this.axios.post('/api/userDetail/update.do',this.userDetail).then(r=>{
        if(r.data.code==200){
          this.$toast("亲，修改信息成功");
          this.$router.push("/updateData");
        }else {
          this.$toast(r.data.msg);
        }
      })
    }
  }
}
</script>

<style scoped>


</style>